<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function passIntoMicro(fn) {
        if (typeof Promise === "function") {
          Promise.resolve().then(fn);
          return;
        }
        if (typeof MutationObserver === "function") {
          const ob = new MutationObserver(fn);
          const node = document.createTextNode("");
          ob.observe(node, { characterData: true });
          node.data = 1;
          return;
        }
        /**
         * 如果是node环境
         */
        if (typeof process.next === "function") {
          process.next(fn);
          return;
        }
        if (typeof setImmediate === "function") {
          setImmediate(fn);
          return;
        }
        setTimeout(fn, 0);
      }
      setImmediate(function(){
        console.log(12);
      })
    </script>
  </body>
</html>
